package com.xiaomi.dao.impl;

import com.xiaomi.dao.TypeDao;
import com.xiaomi.entity.Type;
import com.xiaomi.utils.C3P0Utils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.util.List;

/**
 * TODO
 *
 * @author jy
 * @date 2021/5/24
 */
public class TypeDaoImpl implements TypeDao {

    private final QueryRunner queryRunner = new QueryRunner(C3P0Utils.getDataSource());

    @Override
    public List<Type> typeListToJson() throws Exception {
        String sql = "select * from type";
        return queryRunner.query(sql, new BeanListHandler<>(Type.class));
    }
}
